<template>
  <div>
    <button @click="getRef">获取组件上的ref</button>
    <MyHeader ref='HeaderComp'/>
    <hr />
    <Count />
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader";
import Count from "./components/Count";
export default {
  name: "App",
  components: {
    MyHeader,
    Count,
  },
  methods:{
    getRef(){
      // 把ref属性写在组件上，$refs对象上保存的是组件实例
      console.log(this);
      console.log(this.$refs);
      console.log(this.$refs.HeaderComp);
    }
  }
};
</script>

<style scoped>
</style>